package Proxy.java.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Customer {

    public static void main(String[] args) {
        //在com.sun.proxy目录下
        System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");

        //获得接口实现对象
        Maotaijiu maotaijiu = new Maotaijiu();
        Wuliangye wuliangye = new Wuliangye();

        //【*区别*】获得代理方法内容
        InvocationHandler invocationHandler = new InterfaceInvocationHandler(maotaijiu);

        //生成动态代理对象
        Wine dynamicProxy = (Wine) Proxy.newProxyInstance(Maotaijiu.class.getClassLoader(), Maotaijiu.class.getInterfaces(),invocationHandler);

        //调用动态代理方法
        dynamicProxy.SellWine();

    }

}
